import tipComponent from 'components/common/errorTip.vue';

let $vm, tip = {};

tip.install = function(Vue, options) {
    if (!$vm) {
        const tipPlugin = Vue.extend(tipComponent);

        $vm = new tipPlugin({
            el: document.createElement('div')
        })

        document.body.appendChild($vm.$el)
    }

    $vm.show = false;

    let tip = {
        show(option) {
            $vm.show = true;
            $vm = Object.assign($vm, option);
        },
        hide() {
            $vm.show = false
        }
    }

    if (!Vue.tip) {
        Vue.$tip = tip;
    }

    Vue.prototype.$tip = Vue.$tip

}

export default tip